import { SuitConfig } from "../../../resource/SuitConfig";
import { SuitInfo } from "../../../resource/info/SuitInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { EItemUpdateOper } from "../../../../../Message/Game/EItemUpdateOper";
import { ItemData } from "../../../resource/info/ItemData";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EEquip } from "../../../../../Message/Public/EEquip";
import { EPrefix } from "../../../../../Message/Public/EPrefix";
import { CareerUtil } from "./CareerUtil";
import { JewelUtil } from "./JewelUtil";
import { EquipAdvanceConfig } from "../../../resource/EquipAdvanceConfig";
import { EquipmentModuleConst } from "../../equipment/data/EquipmentModuleConst";
import { TItem } from "../../../../../Message/Db/Tables/TItem";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { Cache } from "../../../cache/Cache";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { TItemSuit } from "../../../../../Message/Db/Tables/TItemSuit";
import { DefInfo } from "../../../resource/info/DefInfo";
import { EJewel } from "../../../../../Message/Public/EJewel";
import { TItemWeapon } from "../../../../../Message/Db/Tables/TItemWeapon";
import { EquipmentItemDataUtil } from "../EquipmentItemDataUtil";
import { SPlayerItemUpdate } from "../../../../../Message/Game/SPlayerItemUpdate";
import { ItemConfig } from "../../../resource/ItemConfig";
import { WardrobeType } from "../../wardrobe/WardrobeType";
import { ItemExInfo } from "../../../resource/info/ItemExInfo";
type int = number;
//class EquipmentUtil
    
    export  class EquipmentUtil
    {
        

        public static getSuitTipByCode(arg1: int, arg2: Boolean): string
        {
            var loc9=null;
            var loc10=0;
            var loc11=null;
            var loc12=0;
            var loc13=null;
            var loc14=null;
            var loc1="";
            var loc2="";
            var loc3="";
            var loc4=[];
            var loc5="";
            var loc6="";
            var loc7=0;
            var loc8;
            if (loc8 = SuitConfig.instance.getInfoByCode(arg1)) 
            {
                loc7 = (loc9 = new SuitInfo(loc8)).num;
                loc4 = loc9.partList;
                loc10 = 0;
                while (loc10 < loc4.length) 
                {
                    loc13 = "";
                    loc14 = "";
                    if (loc10 == 3) 
                    {
                        loc13 = "\r";
                    }
                    if (loc10 == 0 || loc10 == 4) 
                    {
                        loc14 = "    ";
                    }
                    loc5 = loc5 + (loc14 + HTMLUtil.addColor(loc4[loc10], "#00ff00") + "  " + loc13);
                    ++loc10;
                }
                loc2 = HTMLUtil.addColor(loc8.name + "（" + loc8.num + "/" + loc8.num + "）", "#FF00FF");
                if (arg2) 
                {
                    loc3 = HTMLUtil.addColor(Language.getString(35957), "#f0ea3f");
                }
                else 
                {
                    loc3 = HTMLUtil.addColor(Language.getString(35958), "#00ff00");
                }
                loc2 = loc2 + (" " + loc3);
                loc12 = 1;
                while (loc12 <= loc7) 
                {
                    if ((loc11 = loc9.addAttrArray[(loc12 - 1)]) != "") 
                    {
                        loc6 = loc6 + HTMLUtil.addColor("    （" + loc12 + "）" + loc11 + "\r", "#f0ea3f");
                    }
                    ++loc12;
                }
                loc1 = loc2 + "\r" + loc5 + "\r" + loc6;
            }
            return "<textFormat leading=\'5\'>" + loc1 + "</textFormat>";
        }

        public static isPetEquipUpdateOper(arg1: int): Boolean
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case EItemUpdateOper._EItemUpdatePetEquipUpgradeStar: case EItemUpdateOper._EItemUpdatePetEquipRecast: case EItemUpdateOper._EItemUpdatePetEquipUpgradePrefix: case EItemUpdateOper._EItemUpdatePetEquipRefresh: case EItemUpdateOper._EItemUpdatePetEquipTransform: case EItemUpdateOper._EItemUpdateOperPetEquipStrengthen: case EItemUpdateOper._EItemUpdateOperPetEquipAdvance:
                {
                    return true;
                }
            }
            return false;
        }

        public static isHighestPrefix(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.category == ECategory._ECategoryEquip && arg1.itemInfo && arg1.itemExInfo) 
            {
                if (arg1.itemExInfo.prefix >= EquipmentUtil.getEquipHighestPrefix(arg1)) 
                {
                    return true;
                }
            }
            return false;
        }

        public static getEquipHighestPrefix(arg1: ItemData): int
        {
            if (arg1 && arg1.category == ECategory._ECategoryEquip && arg1.itemInfo && arg1.itemExInfo) 
            {
                if (arg1.type == EEquip._EEquipHeartLock) 
                {
                    return 200;
                }
                if (arg1.type == EEquip._EEquipFashion || arg1.type == EEquip._EEquipFashionWeapon || arg1.type == EEquip._EEquipWing || arg1.type == EEquip._EEquipFootPrint || arg1.type == EEquip._EEquipBubble || arg1.type == EEquip._EEquipSurround || arg1.type == EEquip._EEquipWaistBelt || arg1.type == EEquip._EEquipElf) 
                {
                    return EPrefix._EPrefixPiDi;
                }
                if (arg1.itemInfo.item.level < 60) 
                {
                    return EPrefix._EPrefixPerfect;
                }
                if (arg1.itemInfo.item.level >= 60 && arg1.itemInfo.item.level < 80) 
                {
                    return EPrefix._EPrefixHoly;
                }
                if (arg1.itemInfo.item.level >= 80) 
                {
                    return EPrefix._EPrefixHunDun;
                }
            }
            return 0;
        }

        public static isPetEquipHighestPrefix(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.category == ECategory._ECategoryPetEquip && arg1.itemInfo && arg1.itemExInfo) 
            {
                if (arg1.itemExInfo.prefix >= petEquipHighestPrefix) 
                {
                    return true;
                }
            }
            return false;
        }

        public static get petEquipHighestPrefix(): int
        {
            return EPrefix._EPrefixHunDun;
        }

        public static isMagicEquip(arg1: int): Boolean
        {
            var loc2=0;
            var loc1=CareerUtil.getEquipCareerArray(arg1);
            var loc3=0;
            var loc4=loc1;
            for(loc2 of loc4) 
            {
                if (!CareerUtil.isMagicCareer(loc2)) 
                {
                    continue;
                }
                return true;
            }
            return false;
        }

        public static isPhysicalEquip(arg1: int): Boolean
        {
            var loc2=0;
            var loc1=CareerUtil.getEquipCareerArray(arg1);
            var loc3=0;
            var loc4=loc1;
            for(loc2 of loc4) 
            {
                if (!CareerUtil.isPhysicalCareer(loc2)) 
                {
                    continue;
                }
                return true;
            }
            return false;
        }

        public static isSuitableJewel(arg1: ItemData, arg2: ItemData, arg3: int=0): Boolean
        {
            if (arg3 != 6) 
            {
                if (JewelUtil.isNormalJewel(arg1)) 
                {
                    return true;
                }
            }
            if (EquipAdvanceConfig.instance.checkJewelEmbed(arg2, arg1.type, arg3)) 
            {
                return true;
            }
            return false;
        }

        public static isCanEmbedDoubleJewel(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.itemInfo.item.color == EquipmentModuleConst.EquipmentType_RedGold && arg1.itemInfo.item.level >= 100) 
            {
                return true;
            }
            return false;
        }

        public static jewelPropertyTips(arg1: TItem): string
        {
            var loc1=null;
            if (arg1 && arg1.category == ECategory._ECategoryJewel && arg1.itemLevel == 9) 
            {
                loc1 = EquipmentUtil.getJewelTipsFromCode(arg1);
            }
            else if (arg1.itemLevel <= 8) 
            {
                loc1 = "+" + arg1.effect;
            }
            return loc1;
        }

        public static getJewelTipsFromCode(arg1: TItem): string
        {
            var loc1="";
            var loc2=new ItemData(arg1.effect);
            var loc3=new ItemData(arg1.effectEx);
            if (loc2 && loc3) 
            {
                loc1 = GameDefConfig.instance.getEJewel(loc2.type).name + "+" + loc2.effect + "、" + GameDefConfig.instance.getEJewel(loc3.type).name + "+" + loc3.effect;
            }
            return loc1;
        }

        public static getBaseAdditive(arg1: int, arg2: int, arg3: int, arg4: int): int
        {
            var loc1=0;
            if (arg2 > 0 || arg4 > 0) 
            {
                loc1 = Math.ceil(arg1 * (1 + 0.01 * arg3) - arg1);
            }
            return loc1;
        }

        public static getRoleEquipedSuitPartNum(arg1: int): int
        {
            var loc3=null;
            var loc1=0;
            var loc2=Cache.instance.pack.rolePackCache.getAllItems();
            var loc4=new Map<any, any> /* flash.utils.Dictionary */();
            var loc5=0;
            while (loc5 < loc2.length) 
            {
                loc3 = loc2[loc5] as ItemData;
                if (ItemsUtil.isSuitEquip(loc3) && loc3.itemInfo.extend.suit == arg1) 
                {
                    if (!loc4[loc3.itemCode]) 
                    {
                        ++loc1;
                    }
                    loc4[loc3.itemCode] = loc3;
                }
                ++loc5;
            }
            return loc1;
        }

        public static getRoleEquipedSuitPart(arg1: int): ItemData
        {
            var loc2=null;
            var loc1=Cache.instance.pack.rolePackCache.getAllItems();
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                loc2 = loc1[loc3] as ItemData;
                if (ItemsUtil.isSuitEquip(loc2) && loc2.itemInfo.extend.suit == arg1) 
                {
                    return loc2;
                }
                ++loc3;
            }
            return null;
        }

        public static suitAttrWillLostCheck(arg1: ItemData, arg2: Boolean): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc1=null;
            var loc3=0;
            var loc4=0;
            var loc5=null;
            var loc6=0;
            var loc7=null;
            var loc2;
            if ((loc2 = Cache.instance.role.suitLockedCodes).length > 0) 
            {
                loc6 = 0;
                while (loc6 < loc2.length) 
                {
                    loc3 = loc2[loc6] as int;
                    if ((loc4 = EquipmentUtil.getRoleEquipedSuitPartNum(loc3)) == 1) 
                    {
                        loc1 = new Map<any, any> /* flash.utils.Dictionary */();
                        loc1["isLost"] = false;
                        loc1["itemData"] = null;
                        loc5 = EquipmentUtil.getRoleEquipedSuitPart(loc3);
                        if (arg2) 
                        {
                            if (loc5.type == arg1.type) 
                            {
                                loc1["isLost"] = true;
                                loc7 = SuitConfig.instance.getInfoByCode(loc3);
                            }
                        }
                        else if (arg1.uid == loc5.uid) 
                        {
                            loc1["isLost"] = true;
                            loc7 = SuitConfig.instance.getInfoByCode(loc3);
                        }
                        loc1["itemSuit"] = loc7;
                        loc1["itemData"] = loc5;
                    }
                    ++loc6;
                }
            }
            return loc1;
        }

        public static suitAttrUnlockAlert(arg1: ItemData, arg2: Boolean, arg3: Function, arg4: Object): void
        {
            var itemData: ItemData;
            var isRepalce: Boolean;
            var callBack: Function;
            var data: Object;
            var checkDict: Map<any, any> /* flash.utils.Dictionary */;
            var itemSuit: TItemSuit;
            var onAlertClick: Function;

            var loc1;
            itemSuit = null;
            itemData = arg1;
            isRepalce = arg2;
            callBack = arg3;
            data = arg4;
            if (callBack != null) 
            {
                callBack(data);
            }
            return;
        }

        public static getSelfCareerAttribute(arg1: int, arg2: Map<any, any> /* flash.utils.Dictionary */): Array<any>
        {
            var loc2=undefined;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc8=0;
            var loc1=[];
            var loc9=0;
            var loc10=arg2;
            for (loc2 in loc10) 
            {
                loc1.push(loc2);
            }
            loc3 = [];
            loc8 = 0;
            while (loc8 < loc1.length) 
            {
                loc5 = null;
                loc4 = new DefInfo();
                loc6 = loc1[loc8];
                loc7 = arg2[loc6];
                if ((loc6 == EJewel._EJewelPhysicalAttack || loc6 == EJewel._EJewelPhysicalCrit) && CareerUtil.isPhysicalCareer(arg1)) 
                {
                    loc5 = GameDefConfig.instance.getEJewel(loc6);
                }
                else if ((loc6 == EJewel._EJewelMagicAttack || loc6 == EJewel._EJewelMagicCrit) && CareerUtil.isMagicCareer(arg1)) 
                {
                    loc5 = GameDefConfig.instance.getEJewel(loc6);
                }
                else if (!(loc6 == EJewel._EJewelPhysicalAttack) && !(loc6 == EJewel._EJewelPhysicalCrit) && !(loc6 == EJewel._EJewelMagicAttack) && !(loc6 == EJewel._EJewelMagicCrit)) 
                {
                    loc5 = GameDefConfig.instance.getEJewel(loc6);
                }
                if (loc5) 
                {
                    loc4.name = loc5.name;
                    loc4.id = loc6;
                    if (loc6 == EJewel._EJewelPhysicalAttack || loc6 == EJewel._EJewelMagicAttack) 
                    {
                        loc4.name = Language.getString(36305);
                    }
                    else if (loc6 == EJewel._EJewelPhysicalCrit || loc6 == EJewel._EJewelMagicCrit) 
                    {
                        loc4.name = Language.getString(36306);
                    }
                    else if (loc6 != EJewel._EJewelPhysicalDefense) 
                    {
                        if (loc6 == EJewel._EJewelMagicDefense) 
                        {
                            loc4.name = Language.getString(36308);
                        }
                    }
                    else 
                    {
                        loc4.name = Language.getString(36307);
                    }
                    loc4.value = loc7;
                    loc3.push(loc4);
                }
                ++loc8;
            }
            return loc3;
        }

        public static getCurRolePackEquipsData(arg1: Array<any>): Array<any>
        {
            var loc2=null;
            var loc3=null;
            var loc7=0;
            var loc8=null;
            var loc11=null;
            var loc12=null;
            if (arg1 == null) 
            {
                return [];
            }
            var loc1=[];
            var loc4=new Map<any, any> /* flash.utils.Dictionary */();
            var loc5=[];
            var loc6=1;
            loc4[EJewel._EJewelPhysicalAttack] = [];
            loc4[EJewel._EJewelMagicAttack] = [];
            loc4[EJewel._EJewelPhysicalDefense] = [];
            loc4[EJewel._EJewelMagicDefense] = [];
            loc4[EJewel._EJewelPower] = [];
            loc4[EJewel._EJewelAgile] = [];
            loc4[EJewel._EJewelHabitus] = [];
            loc4[EJewel._EJewelBrains] = [];
            loc4[EJewel._EJewelSpiritual] = [];
            var loc9=0;
            while (loc9 < arg1.length) 
            {
                if ((loc8 = arg1[loc9] as ItemData) && loc8.category == ECategory._ECategoryEquip && loc8.type <= EEquip._EEquipJewelry) 
                {
                    loc1.push(loc8);
                }
                ++loc9;
            }
            var loc10=0;
            while (loc10 < loc1.length) 
            {
                loc2 = loc1[loc10] as ItemData;
                if (loc2) 
                {
                    loc3 = loc2.itemInfo.extend as TItemWeapon;
                    if (loc2.itemExInfo) 
                    {
                        loc7 = loc2.itemExInfo.prefix;
                    }
                    loc6 = EquipmentItemDataUtil.getAddPercentage(loc7, loc2.type);
                    if (loc3) 
                    {
                        if (loc3.basePhysicalAttack != 0) 
                        {
                            loc4[EJewel._EJewelPhysicalAttack].push(int(loc6 * loc3.basePhysicalAttack));
                        }
                        if (loc3.baseMagicAttack != 0) 
                        {
                            loc4[EJewel._EJewelMagicAttack].push(int(loc6 * loc3.baseMagicAttack));
                        }
                        if (loc3.basePhysicalDefense != 0) 
                        {
                            loc4[EJewel._EJewelPhysicalDefense].push(int(loc6 * loc3.basePhysicalDefense));
                        }
                        if (loc3.baseMagicDefense != 0) 
                        {
                            loc4[EJewel._EJewelMagicDefense].push(int(loc6 * loc3.baseMagicDefense));
                        }
                        if (loc3.basePower != 0) 
                        {
                            loc4[EJewel._EJewelPower].push(int(loc6 * loc3.basePower));
                        }
                        if (loc3.baseAgile != 0) 
                        {
                            loc4[EJewel._EJewelAgile].push(int(loc6 * loc3.baseAgile));
                        }
                        if (loc3.baseHabitus != 0) 
                        {
                            loc4[EJewel._EJewelHabitus].push(int(loc6 * loc3.baseHabitus));
                        }
                        if (loc3.baseBrains != 0) 
                        {
                            loc4[EJewel._EJewelBrains].push(int(loc6 * loc3.baseBrains));
                        }
                        if (loc3.baseSpiritual != 0) 
                        {
                            loc4[EJewel._EJewelSpiritual].push(int(loc6 * loc3.baseSpiritual));
                        }
                    }
                }
                ++loc10;
            }
            var loc13=0;
            var loc14=loc4;
            for (loc11 in loc14) 
            {
                loc12 = {};
                if (!((loc4[parseInt(loc11)] as Array<any>).length > 0)) 
                {
                    continue;
                }
                loc12.nameInt = parseInt(loc11);
                loc12.value = loc4[parseInt(loc11)] as Array<any>;
                if (parseInt(loc11) != EJewel._EJewelPower) 
                {
                    if (parseInt(loc11) != EJewel._EJewelAgile) 
                    {
                        if (parseInt(loc11) != EJewel._EJewelHabitus) 
                        {
                            if (parseInt(loc11) != EJewel._EJewelBrains) 
                            {
                                if (parseInt(loc11) != EJewel._EJewelSpiritual) 
                                {
                                    if (parseInt(loc11) != EJewel._EJewelPhysicalAttack) 
                                    {
                                        if (parseInt(loc11) != EJewel._EJewelMagicAttack) 
                                        {
                                            if (parseInt(loc11) != EJewel._EJewelPhysicalDefense) 
                                            {
                                                if (parseInt(loc11) == EJewel._EJewelMagicDefense) 
                                                {
                                                    loc12.name = Language.getString(90241);
                                                }
                                            }
                                            else 
                                            {
                                                loc12.name = Language.getString(90240);
                                            }
                                        }
                                        else 
                                        {
                                            loc12.name = Language.getString(90239);
                                        }
                                    }
                                    else 
                                    {
                                        loc12.name = Language.getString(90238);
                                    }
                                }
                                else 
                                {
                                    loc12.name = Language.getString(71106);
                                }
                            }
                            else 
                            {
                                loc12.name = Language.getString(71105);
                            }
                        }
                        else 
                        {
                            loc12.name = Language.getString(71104);
                        }
                    }
                    else 
                    {
                        loc12.name = Language.getString(71103);
                    }
                }
                else 
                {
                    loc12.name = Language.getString(71102);
                }
                loc5.push(loc12);
            }
            loc5.sortOn("nameInt", Array.NUMERIC);
            return loc5;
        }

        public static isHaveJewel(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.category == ECategory._ECategoryEquip && arg1.itemExInfo) 
            {
                if (arg1.itemExInfo.hole1 > 1 || arg1.itemExInfo.hole2 > 1 || arg1.itemExInfo.hole3 > 1 || arg1.itemExInfo.hole4 > 1 || arg1.itemExInfo.hole5 > 1 || arg1.itemExInfo.hole6 > 1) 
                {
                    return true;
                }
                return false;
            }
            return false;
        }

        public static isAllLock(arg1: Map<any, any> /* flash.utils.Dictionary */): Boolean
        {
            if (arg1) 
            {
                if (arg1.hasOwnProperty(1) && arg1.hasOwnProperty(2) && arg1.hasOwnProperty(3) && arg1.hasOwnProperty(4) && arg1.hasOwnProperty(5) && arg1.hasOwnProperty(6)) 
                {
                    return true;
                }
            }
            return false;
        }

        public static getMagicItemArr(arg1: Array<any>): Array<any>
        {
            var loc3=null;
            var loc5=null;
            var loc6=null;
            var loc1=arg1.length;
            var loc2=[];
            var loc4=0;
            while (loc4 < arg1.length) 
            {
                if ((loc5 = arg1[loc4]) is SPlayerItemUpdate) 
                {
                    loc6 = loc5 as SPlayerItemUpdate;
                    loc3 = new ItemData(loc6.playerItem);
                    loc2.push(loc3);
                }
                ++loc4;
            }
            return loc2;
        }

        public static setPlayerEequipArr(arg1: Array<any>): Array<any>
        {
            var loc6=null;
            var loc7=null;
            var loc1=arg1;
            var loc2=loc1.length;
            var loc3=[];
            var loc4=0;
            var loc5=Cache.instance.pack.rolePackCache.sbag.capacity;
            loc4 = 0;
            while (loc4 < loc5) 
            {
                loc3.push(null);
                ++loc4;
            }
            loc4 = 0;
            while (loc4 < loc2) 
            {
                if ((loc6 = loc1[loc4] as SPlayerItemUpdate).playerItem) 
                {
                    loc7 = new ItemData(loc6.playerItem);
                    loc3[(loc6.posIndex - 1)] = loc7;
                }
                ++loc4;
            }
            return loc3;
        }

        public static getAllEquipItemArr(arg1: Array<any>): Array<any>
        {
            var loc3=null;
            var loc4=null;
            var loc1=arg1.length;
            var loc2=[];
            var loc5=0;
            while (loc5 < loc1) 
            {
                if ((loc3 = arg1[loc5] is ItemData ? arg1[loc5] : null) && !(loc3 == ItemData.nullItemData)) 
                {
                    loc4 = ItemConfig.instance.getInfoByCode(loc3.itemCode);
                    var loc6=loc4.item.category;
                    switch (loc6) 
                    {
                        case ECategory._ECategoryEquip: case ECategory._ECategoryRune: case ECategory._ECategoryMount: case ECategory._ECategoryPetEquip: case ECategory._ECategorySpiritEquip: case ECategory._ECategoryAmulet:
                        {
                            loc2.push(loc3);
                            break;
                        }
                    }
                }
                ++loc5;
            }
            return loc2;
        }

        public static isOwnEquip(arg1: ItemData): int
        {
            var loc5=false;
            var loc6=null;
            var loc7=null;
            var loc1=false;
            var loc2=[];
            var loc3=Cache.instance.wardrobe;
            var loc4=0;
            if (arg1 && arg1.category == ECategory._ECategoryEquip) 
            {
                if (arg1.type == EEquip._EEquipWing) 
                {
                    return loc3.isOwnWing(arg1) ? 1 : 2;
                }
                if (arg1.type != EEquip._EEquipFashion) 
                {
                    if (arg1.type != EEquip._EEquipFashionWeapon) 
                    {
                        if (arg1.type != EEquip._EEquipFootPrint) 
                        {
                            if (arg1.type != EEquip._EEquipBubble) 
                            {
                                if (arg1.type != EEquip._EEquipSurround) 
                                {
                                    if (arg1.type != EEquip._EEquipWaistBelt) 
                                    {
                                        if (arg1.type != EEquip._EEquipElf) 
                                        {
                                            if (arg1.type == EEquip._EEquipHeartLock) 
                                            {
                                                loc2 = EquipmentUtil.getNormalEquips(ItemsUtil.isHeartLock);
                                                loc4 = 0;
                                                while (loc4 < loc2.length) 
                                                {
                                                    if ((loc6 = loc2[loc4]) && loc6.itemInfo.modelId == arg1.itemInfo.modelId) 
                                                    {
                                                        loc1 = true;
                                                        break;
                                                    }
                                                    ++loc4;
                                                }
                                                if (loc1) 
                                                {
                                                    return 1;
                                                }
                                                return 2;
                                            }
                                            return 0;
                                        }
                                        else 
                                        {
                                            loc3.getallELF();
                                            loc2 = loc3.getActiveFashion(WardrobeType.WardrobeElf);
                                        }
                                    }
                                    else 
                                    {
                                        loc3.getallWaistBelt();
                                        loc2 = loc3.getActiveFashion(WardrobeType.WardrobeWaistBelt);
                                    }
                                }
                                else 
                                {
                                    loc3.getallSurround();
                                    loc2 = loc3.getActiveFashion(WardrobeType.WardrobeSurroung);
                                }
                            }
                            else 
                            {
                                loc3.getallBubble();
                                loc2 = loc3.getActiveFashion(WardrobeType.WardrobeBubble);
                            }
                        }
                        else 
                        {
                            loc3.getallFootPrint();
                            loc2 = loc3.getActiveFashion(WardrobeType.WardrobeFootPrint);
                        }
                    }
                    else 
                    {
                        loc3.getAllFashionWeapon();
                        loc2 = loc3.getActiveFashion(WardrobeType.WardrobeFashionWeapon);
                    }
                }
                else 
                {
                    loc3.getAllFashion();
                    loc2 = loc3.getActiveFashion(WardrobeType.WardrobeFashion);
                }
            }
            else 
            {
                return 0;
            }
            if (loc2 && loc2.length > 0) 
            {
                loc4 = 0;
                while (loc4 < loc2.length) 
                {
                    if ((loc7 = loc2[loc4].wardrobeItemInfo) && loc7.itemData && loc7.itemData.itemInfo.modelId == arg1.itemInfo.modelId) 
                    {
                        loc1 = true;
                    }
                    ++loc4;
                }
            }
            if (!loc1) 
            {
                if (loc5 = Cache.instance.pack.backPackCache.isSameModelIdByItemData(arg1)) 
                {
                    loc1 = true;
                }
            }
            if (!loc1) 
            {
                if (loc5 = Cache.instance.pack.wareHousePackCache.isSameModelIdByItemData(arg1)) 
                {
                    loc1 = true;
                }
            }
            if (loc1) 
            {
                return 1;
            }
            return 2;
        }

        /* internal  */static getNormalEquips(arg1: Function): Array<any>
        {
            var loc1=[];
            loc1 = loc1.concat(Cache.instance.pack.backPackCache.getItemsByJudge(arg1));
            loc1 = loc1.concat(Cache.instance.pack.wareHousePackCache.getItemsByJudge(arg1));
            loc1 = loc1.concat(Cache.instance.pack.rolePackCache.getItemsByJudge(arg1));
            return loc1;
        }

        public static getAttrArray(arg1: string, arg2: int=-1): Array<any>
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            var loc1=[];
            if (arg1 && !(arg1 == "")) 
            {
                loc2 = arg1.split("#");
                loc6 = 0;
                while (loc6 < loc2.length) 
                {
                    loc3 = (loc2[loc6] as string).split(",");
                    loc5 = int(loc3[0]);
                    if (CareerUtil.isPhysicalCareer(arg2)) 
                    {
                        if (!(loc5 == EJewel._EJewelMagicAttack || loc5 == EJewel._EJewelMagicCrit)) 
                        {
                            if (loc3.length == 2) 
                            {
                                (loc4 = new Map<any, any> /* flash.utils.Dictionary */())["name"] = GameDefConfig.instance.getEJewel(loc5).name;
                                loc4["value"] = int(loc3[1]);
                                if (loc5 == EJewel._EJewelPhysicalAttack || loc5 == EJewel._EJewelMagicAttack) 
                                {
                                    loc4["name"] = Language.getString(36305);
                                }
                                else if (loc5 == EJewel._EJewelPhysicalCrit || loc5 == EJewel._EJewelMagicCrit) 
                                {
                                    loc4["name"] = Language.getString(36306);
                                }
                                else if (loc5 != EJewel._EJewelPhysicalDefense) 
                                {
                                    if (loc5 == EJewel._EJewelMagicDefense) 
                                    {
                                        loc4["name"] = Language.getString(36308);
                                    }
                                }
                                else 
                                {
                                    loc4["name"] = Language.getString(36307);
                                }
                                loc1.push(loc4);
                            }
                        }
                    }
                    else if (!(loc5 == EJewel._EJewelPhysicalAttack || loc5 == EJewel._EJewelPhysicalCrit)) 
                    {
                        if (loc3.length == 2) 
                        {
                            (loc4 = new Map<any, any> /* flash.utils.Dictionary */())["name"] = GameDefConfig.instance.getEJewel(loc5).name;
                            loc4["value"] = int(loc3[1]);
                            if (loc5 == EJewel._EJewelPhysicalAttack || loc5 == EJewel._EJewelMagicAttack) 
                            {
                                loc4["name"] = Language.getString(36305);
                            }
                            else if (loc5 == EJewel._EJewelPhysicalCrit || loc5 == EJewel._EJewelMagicCrit) 
                            {
                                loc4["name"] = Language.getString(36306);
                            }
                            else if (loc5 != EJewel._EJewelPhysicalDefense) 
                            {
                                if (loc5 == EJewel._EJewelMagicDefense) 
                                {
                                    loc4["name"] = Language.getString(36308);
                                }
                            }
                            else 
                            {
                                loc4["name"] = Language.getString(36307);
                            }
                            loc1.push(loc4);
                        }
                    }
                    ++loc6;
                }
            }
            return loc1;
        }

        public static isHaveFashionJewelChatInfo(arg1: ItemExInfo, arg2: int): Boolean
        {
            if (arg1) 
            {
                var loc1=arg2;
                switch (loc1) 
                {
                    case EEquip._EEquipFashion:
                    {
                        if (arg1.fjew_fa != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipFashionWeapon:
                    {
                        if (arg1.fjew_we != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipWing:
                    {
                        if (arg1.fjew_wi != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipFootPrint:
                    {
                        if (arg1.fjew_fr != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipBubble:
                    {
                        if (arg1.fjew_bu != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipSurround:
                    {
                        if (arg1.fjew_su != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipWaistBelt:
                    {
                        if (arg1.fjew_wb != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    case EEquip._EEquipElf:
                    {
                        if (arg1.fjew_el != "") 
                        {
                            return true;
                        }
                        return false;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return false;
        }

        public static getFshionJewelChatInfo(arg1: ItemExInfo, arg2: int): Array<any>
        {
            var loc1=[];
            if (arg1) 
            {
                var loc2=arg2;
                switch (loc2) 
                {
                    case EEquip._EEquipFashion:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_fa);
                    }
                    case EEquip._EEquipFashionWeapon:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_we);
                    }
                    case EEquip._EEquipWing:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_wi);
                    }
                    case EEquip._EEquipFootPrint:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_fr);
                    }
                    case EEquip._EEquipBubble:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_bu);
                    }
                    case EEquip._EEquipSurround:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_su);
                    }
                    case EEquip._EEquipWaistBelt:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_wb);
                    }
                    case EEquip._EEquipElf:
                    {
                        return Cache.instance.wardrobe.getChatFashionJewelInfo(arg1.fjew_el);
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return loc1;
        }
    }
